package com.itheima.myException;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Student s = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = sc.nextLine();
        s.setName(name);
        while (true) {
            System.out.println("请输入年龄");
            String studentAge = sc.nextLine();
            try {
                int age = Integer.parseInt(studentAge);
                s.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
            } catch (AgeOutOfBoundsException e){
                System.out.println("请输入一个符合范围的年龄");

            }
        }
            System.out.println(s);
    }
}
